﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using MVC.PagerHelper.Interfaces;
using MVC.PagerHelper.Models;

namespace Jinshiyu.Models
{
    public class OrderViewModel : IValidatableObject
    {
        [Key]
        public int 订单编号 { get; set; }

        [Display(Name = "用户名")]
        public string 账户 { get; set; }

        [Required(ErrorMessage = "*")]
        [DataType(DataType.MultilineText)]
        [Display(Name = "洗车地址")]
        public string Address { get; set; }

        [Required(ErrorMessage = "*")]
        [Display(Name = "车型")]
        public string 车型 { get; set; }

        [Required(ErrorMessage = "*")]
        [Display(Name = "车牌号")]
        public string 车牌号 { get; set; }

        [DataType("Color")]
        [Display(Name = "颜色")]
        public string 颜色 { get; set; }

        [DataType(DataType.DateTime)]
        [Display(Name = "预约时间1")]
        public System.DateTime 预约时间1 { get; set; }

        public int 起始时 { get; set; }

        public int 结束时 { get; set; }

        [Display(Name = "洗车类型")]
        public string 洗车类型 { get; set; }

        [Required]
        [DataType(DataType.Currency)]
        [Display(Name = "金额")]
        public decimal 金额 { get; set; }

        [Display(Name = "发票")]
        public bool 发票 { get; set; }

        [Display(Name = "划痕验证")]
        public bool Scratch { get; set; }

        [Editable(false)]
        [Display(Name = "经度")]
        public decimal Longitude { get; set; }

        [Editable(false)]
        [Display(Name = "纬度")]
        public decimal Latitude { get; set; }


        public Nullable<int> 地图级数 { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (起始时 >= 结束时)
                yield return new ValidationResult("预订洗车时间有误，请核对。", new[] { "起始时", "结束时" });
        }
    }

    //带分页的OrderListViewModel
    public class OrderListViewModel : IPageble
    {
        public OrderListViewModel()
        {
            PagerViewModel = new PagerViewModel();
        }

        public PagerViewModel PagerViewModel { get; set; }

        public IEnumerable<Order> ListOfOrders { get; set; }
    }

}